package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MeetingInfo;
import com.ruoyi.system.service.IMeetingInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会议室Controller
 *
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/system/info")
public class MeetingInfoController extends BaseController
{
    @Autowired
    private IMeetingInfoService meetingInfoService;

    /**
     * 查询会议室列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(MeetingInfo meetingInfo)
    {
        startPage();
        List<MeetingInfo> list = meetingInfoService.selectMeetingInfoList(meetingInfo);
        return getDataTable(list);
    }

    /**
     * 查询会议室列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/listAll")
    public AjaxResult listAll(MeetingInfo meetingInfo)
    {

        List<MeetingInfo> list = meetingInfoService.selectMeetingInfoList(meetingInfo);
        return success(list);
    }

    /**
     * 导出会议室列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "会议室", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MeetingInfo meetingInfo)
    {
        List<MeetingInfo> list = meetingInfoService.selectMeetingInfoList(meetingInfo);
        ExcelUtil<MeetingInfo> util = new ExcelUtil<MeetingInfo>(MeetingInfo.class);
        util.exportExcel(response, list, "会议室数据");
    }

    /**
     * 获取会议室详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{meetingId}")
    public AjaxResult getInfo(@PathVariable("meetingId") Long meetingId)
    {
        return success(meetingInfoService.selectMeetingInfoByMeetingId(meetingId));
    }

    /**
     * 新增会议室
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "会议室", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MeetingInfo meetingInfo)
    {
        return toAjax(meetingInfoService.insertMeetingInfo(meetingInfo));
    }

    /**
     * 修改会议室
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "会议室", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MeetingInfo meetingInfo)
    {
        return toAjax(meetingInfoService.updateMeetingInfo(meetingInfo));
    }

    /**
     * 删除会议室
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "会议室", businessType = BusinessType.DELETE)
	@DeleteMapping("/{meetingIds}")
    public AjaxResult remove(@PathVariable Long[] meetingIds)
    {
        return toAjax(meetingInfoService.deleteMeetingInfoByMeetingIds(meetingIds));
    }
}
